package com.dss.auto_deploy.constants;

import com.dss.auto_deploy.dto.JdkVersionDto;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description:
 * @author: dongshoushan
 * @date: 2022年01月14日 13:44
 */
public class AutoConstants {
    /**
     * 普通部署日志路径
     */
    public static final String DEPLOY_INFO_PATH = System.getProperty("user.dir")+ "/logs/lenovo/cnbu/commonDeploy/deploy.log";
    public static final String DEPLOY_INFO_PATH_PREFIX =System.getProperty("user.dir")+ "/logs/lenovo/cnbu/commonDeploy/";
    /**
     * docker部署日志路径
     */
    public static final String DOCKER_DEPLOY_INFO_PATH =System.getProperty("user.dir")+ "/logs/lenovo/cnbu/dockerDeploy/deploy.log";
    public static final String DOCKER_DEPLOY_INFO_PATH_PREFIX =System.getProperty("user.dir")+ "/logs/lenovo/cnbu/dockerDeploy/";
    public static final String baseLocalPath =  System.getProperty("user.dir")+ "/temp/config/docker/";
    public static final String EMPTY_PATH =  System.getProperty("user.dir")+ "/temp/empty/";
    /**
     * 关闭防火墙
     */
    public static final String DISABLE_FIREWALLD =  "systemctl disable firewalld";
    public static final String STOP_FIREWALLD =  "systemctl stop firewalld";
    /**
     * 删除仓库文件
     */
    public static final String GET_REGISTRY_256 =  "curl --header \"Accept:application/vnd.docker.distribution.manifest.v2+json\" -I -XGET  http://{}:{}/v2/{}/manifests/{}";
    /**
     * 删除仓库文件
     */
    public static final String DEL_REGISTRY =  "curl -I -XDELETE http://{}:{}/v2/{}/manifests/{}";
    /**
     * 仓库删除镜像垃圾回收
     */
    public static final String GARBAGE_COLLECTION  =  "docker exec registry bin/registry garbage-collect /etc/docker/registry/config.yml";
    /**
     * 导出镜像
     */
    public static final String SAVE_IMAGES  =  "docker save -o {}/{}.{}.tar {}";
    /**
     * 加载镜像
     */
    public static final String LOAD_IMAGES  =  "docker load -i {}/{}";
    /**
     * 临时目录
     */
    public static final String LINUX_TEMP_PATH  =  "/data/temp";
    public static final String AUTHORIZATION_FOLDER  =  "sudo chmod 777 -R ";
    /**
     * 代码自动部署路径
     */
    public static final String GIT_WORKSPACE =  "workspace_git";
    public static final String DOCKER_DOWNLOAD_TEMP_PATH =  "/docker_download/temp";

    public static final String SQL_PATH = "/项目名称/{}/上线文件/sql";
    public static final String DRIVER_NAME = "com.mysql.cj.jdbc.Driver";
    public static final String LINUX_TEMP_FILE_PREFIX = "/linux/temp/file/edit/{}/{}";
    /**
     * 临时文件 ip+文件名
     */
    public static final String LINUX_TEMP_FILE = LINUX_TEMP_FILE_PREFIX+"/{}";
    public static final String LINUX_DOWNLOAD_FILE_PREFIX = "/linux/temp/file/download/{}/{}";
    /**
     * 下载文件 ip+文件名
     */
    public static final String LINUX_DOWNLOAD_FILE = LINUX_DOWNLOAD_FILE_PREFIX+"/{}";

    public static final List<JdkVersionDto> JDK_VERSION_LIST = new ArrayList<>();
    static {
        JDK_VERSION_LIST.add(JdkVersionDto.builder().version(8).key("jdk8").value("lenovo-jre-py:latest").build());
        JDK_VERSION_LIST.add(JdkVersionDto.builder().version(17).key("jdk17").value("lenovo-jre:17").build());
        JDK_VERSION_LIST.add(JdkVersionDto.builder().version(19).key("jdk19").value("aomountainu/openjdk19:latest").build());
    }


}
